<template>
  <div style="display: flex;flex-direction: column;height:100%;overflow: hidden">
    <div class="top" style="font-size: 14px;margin:20px">
      <span style="color:#A8ABB2">work manage</span> <span style="color:#096dd9;transform: translateY(3px)"> <tiny-icon-clock-work></tiny-icon-clock-work>{{
        Time
      }}</span>
    </div>
    <div class="box">

      <div class="card-box">
        <div class="card" style="">
          <div class="img">
            <svg t="1713356563505" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
                 p-id="7277" width="50" height="50">
              <path
                  d="M631.466667 665.6h-153.6v51.2h153.6v-51.2zM785.066667 512H477.866667v51.2h307.2v-51.2zM785.066667 358.4H477.866667v51.2h307.2v-51.2z"
                  fill="#335056" p-id="7278"></path>
              <path
                  d="M904.533333 204.8H682.666667V85.333333c0-18.773333-15.36-34.133333-34.133334-34.133333H102.4c-18.773333 0-34.133333 15.36-34.133333 34.133333v699.733334c0 18.773333 15.36 34.133333 34.133333 34.133333h221.866667v119.466667c0 18.773333 15.36 34.133333 34.133333 34.133333h546.133333c18.773333 0 34.133333-15.36 34.133334-34.133333V238.933333c0-18.773333-15.36-34.133333-34.133334-34.133333zM324.266667 409.6v102.4h-102.4v51.2h102.4v204.8H119.466667V102.4h512v102.4H221.866667v51.2h102.4v102.4h-102.4v51.2h102.4z m563.2 512H375.466667V256h512v665.6z"
                  fill="#335056" p-id="7279"></path>
              <path
                  d="M221.866667 563.2v-51.2h102.4v-102.4h-102.4v-51.2h102.4v-102.4h-102.4v-51.2h409.6V102.4H119.466667v665.6h204.8V563.2z"
                  fill="#78BDCC" p-id="7280"></path>
            </svg>
          </div>
          <div class="text">
            <div class="title">
              work lists
            </div>
            <span>查看已发布的所有作业</span>
            <button style="background-color: #EBEEF5;color:#5e7ce0" @click="list">点击进入</button>
          </div>
        </div>
        <div class="card" style=" ">
          <div class="img">
            <svg t="1713356593707" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"
                 p-id="7429" width="50" height="50">
              <path d="M192 1024v-224h416V480H192V0h448v384h384v640H192z" fill="#FF9E1F" p-id="7430"></path>
              <path d="M0 576h512v160H0z" fill="#FFD7A4" p-id="7431"></path>
              <path d="M704 0l320 320H704V0z" fill="#FFD7A4" p-id="7432"></path>
            </svg>
          </div>
          <div class="text">
            <div class="title">
               publish work
            </div>
            <span>发布作业</span>
            <button style="background-color: #5e7ce0;color:#ffffff" @click="publishWork">点击进入</button>
          </div>
        </div>
      </div>
      <div class="ciyun">
        <div class="title">
          个人完成情况
        </div>
        <tiny-chart-gauge height="90%" :data="chartData" :settings="chartSettings"></tiny-chart-gauge>
      </div>

    </div>
    <div class="btm">
      <tiny-chart-histogram :data="Data" :settings="chartSetting" height="100%"></tiny-chart-histogram>
    </div>
  </div>
</template>

<script setup>
import time from "../utils/time.js"
import {ref,onMounted,inject} from 'vue'
import {useRouter} from "vue-router";
import {ChartGauge as TinyChartGauge, ChartHistogram as TinyChartHistogram} from '@opentiny/vue'
import {IconStarDisable} from '@opentiny/vue-icon'
const axios = inject('axios')
const TinyIconClockWork = IconStarDisable()
const router = useRouter()
const row = ref([])
onMounted(()=>{
 axios.get("/work/list").then(res=>{
   const number = window.localStorage.getItem("number")
   res.data.data.forEach(item=>{
     row.value.push({
       作业:item.title,
       已完成:item.finished,
       未完成:number - item.finished
     })
   })
 })
})
const Data = ref({
  columns: ['作业', '已完成', '未完成'],
  rows: row.value
})
const list = () => {
  router.push("/workList")
}
const publishWork = ()=>{
  router.push("/publishWork")
}
const chartSetting = ref({})
const Time = time()
const chartData = ref({
  columns: ['type', 'value'],
  rows: [{type: '占比', value: 0.8,}]
})
const chartSettings = ref({
  dataType: {
    占比: 'percent'
  },
  seriesMap: {
    占比: {
      min: 0,
      max: 1
    }
  }
})
</script>

<style scoped lang="less">
.box {
  width: 90%;
  margin: 20px;
  display: flex;
  justify-content: space-between;

  .card {
    width: 220px;
    height: 280px;
    background-color: #ffffff;
    border: 1px solid #EBEEF5;
    margin: 20px;
    border-radius: 10px;

    display: flex;
    flex-direction: column;
    align-items: center;

    .img {

      margin: 30px;
      margin-top: 40px;
    }

    .text {
      display: flex;
      flex-direction: column;
      align-items: center;

      .title {
        color: #5e7ce0;
        font-size: 18px;
        font-weight: 700;
        margin-bottom: 10px;
      }

      span {
        font-size: 12px;
        color: #A8ABB2
      }

    }

    button {
      border: none;
      background-color: #50d4ab;
      width: 140px;
      height: 30px;
      border-radius: 15px;
      margin-top: 20px;
    }


  }

  .ciyun {
    flex: 1;

    .title {
      margin-left: 80px;
      font-size: 18px;
      color: #5e7ce0;
      font-weight: 700;
      transform: translateY(20px);
      padding-bottom: 10px;
      border-bottom: 1px solid #D4D7DE;
    }
  }

  .card-box {
    width: 60%;
    display: flex;
    justify-content: flex-end;
  }

  height: 300px;
}

.btm {
  flex: 1;
  width: 80%;
  margin: 10px auto;
  //transform: translateY(-100px);
  background-color: #ffffff;
}

.tiny-svg {
  fill: #096dd9;
  font-size: 15px;
  margin: 5px;
  font-weight: 700;
  transform: translateY(-2px);
}
</style>